Telegram Group & Telegram Channel
📊 Своя метрика в Prometheus

Хотите отслеживать, сколько запросов прилетает в ваше приложение? Или сколько задач выполнилось? Делается это за 5 шагов — через кастомные метрики.

Попробуем реализовать пример: считаем количество HTTP-запросов в приложении на Go.

1. Подключаем библиотеку Prometheus:
go get github.com/prometheus/client_golang/prometheus


2. Создаём счётчик:
var requestCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "myapp_http_requests_total",
Help: "Total number of HTTP requests",
})


3. Регистрируем метрику:
func init() {
prometheus.MustRegister(requestCounter)
}


requestCounter будет инкрементироваться при запросе приложения.

4. Добавляем endpoint для Prometheus:
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))


5. Пишем конфиг на стороне Prometheus
scrape_configs:
- job_name: 'myapp'
metrics_path: /metrics
static_configs:
- targets: ['localhost:8080']


📍 Всё — теперь http://localhost:8080/metrics отдаёт данные, которые можно добавить в дашборд в Prometheus.

🐸Библиотека devops'a #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/devopsslib/3737
Create:
Last Update:

📊 Своя метрика в Prometheus

Хотите отслеживать, сколько запросов прилетает в ваше приложение? Или сколько задач выполнилось? Делается это за 5 шагов — через кастомные метрики.

Попробуем реализовать пример: считаем количество HTTP-запросов в приложении на Go.

1. Подключаем библиотеку Prometheus:

go get github.com/prometheus/client_golang/prometheus


2. Создаём счётчик:
var requestCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "myapp_http_requests_total",
Help: "Total number of HTTP requests",
})


3. Регистрируем метрику:
func init() {
prometheus.MustRegister(requestCounter)
}


requestCounter будет инкрементироваться при запросе приложения.

4. Добавляем endpoint для Prometheus:
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))


5. Пишем конфиг на стороне Prometheus
scrape_configs:
- job_name: 'myapp'
metrics_path: /metrics
static_configs:
- targets: ['localhost:8080']


📍 Всё — теперь http://localhost:8080/metrics отдаёт данные, которые можно добавить в дашборд в Prometheus.

🐸Библиотека devops'a #буст

BY Библиотека девопса | DevOps, SRE, Sysadmin




Share with your friend now:
tg-me.com/devopsslib/3737

View MORE
Open in Telegram


Библиотека девопса | DevOps SRE Sysadmin Telegram | DID YOU KNOW?

Date: |

How Does Bitcoin Work?

Bitcoin is built on a distributed digital record called a blockchain. As the name implies, blockchain is a linked body of data, made up of units called blocks that contain information about each and every transaction, including date and time, total value, buyer and seller, and a unique identifying code for each exchange. Entries are strung together in chronological order, creating a digital chain of blocks. “Once a block is added to the blockchain, it becomes accessible to anyone who wishes to view it, acting as a public ledger of cryptocurrency transactions,” says Stacey Harris, consultant for Pelicoin, a network of cryptocurrency ATMs. Blockchain is decentralized, which means it’s not controlled by any one organization. “It’s like a Google Doc that anyone can work on,” says Buchi Okoro, CEO and co-founder of African cryptocurrency exchange Quidax. “Nobody owns it, but anyone who has a link can contribute to it. And as different people update it, your copy also gets updated.”

A project of our size needs at least a few hundred million dollars per year to keep going,” Mr. Durov wrote in his public channel on Telegram late last year. “While doing that, we will remain independent and stay true to our values, redefining how a tech company should operate.

Библиотека девопса | DevOps SRE Sysadmin from ua


Telegram Библиотека девопса | DevOps, SRE, Sysadmin
FROM USA